# Maintainer: Arseniy Velikanov <adomerlee@gmail.com>
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-xiaomi-vayu
pkgdesc="Xiaomi POCO X3 Pro"
pkgver=2
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
	linux-postmarketos-qcom-sm8150
	mkbootimg
	postmarketos-base
	make-dynpart-mappings
"
makedepends="devicepkg-dev"
source="
	deviceinfo
	phoc.ini
"

subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-nonfree-firmware-openrc:nonfree_firmware_openrc
	$pkgname-phosh
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

nonfree_firmware() {
	pkgdesc="Firmware for GPU, Audio, Modem, WiFi, etc."
	depends="
		firmware-xiaomi-vayu-adreno
		firmware-xiaomi-vayu-adsp
		firmware-xiaomi-vayu-cdsp
		firmware-xiaomi-vayu-touchscreen
		firmware-xiaomi-vayu-wlan
		firmware-xiaomi-vayu-modem
		firmware-xiaomi-vayu-ath10k
		msm-modem
		pd-mapper
		tqftpserv
		"
	mkdir "$subpkgdir"
}

nonfree_firmware_openrc() {
	install_if="$pkgname-nonfree-firmware=$pkgver-r$pkgrel openrc"
	install="$subpkgname.post-install"
	mkdir "$subpkgdir"
}

phosh() {
	install_if="$pkgname=$pkgver-r$pkgrel phosh"
	install -Dm644 "$srcdir"/phoc.ini \
		"$subpkgdir"/etc/phosh/phoc.ini
}

sha512sums="
593e27a91376866698c8c37f4aec4f3ef6866179d363b71649161faa6421d13f88bdfc26f398838723a840de81a2de25e133046b09d60801ddcad87a79dffb3c  deviceinfo
eef80842915acfa8d8bcbd9ac9fcb057ad912d582e4a78b8ddd9774ef688971d2878b83f4a54adaa1d613dce8645a85ffb25e8a98c55e32a91dfe73002e91fe0  phoc.ini
"
